#include<iostream>
using namespace std;
const int N=100010;
int s[N];
int n=0;
int ans=0;
typedef long long ll ;
ll res;
int main()
{
    cin>>n;
    s[0]=0;
    int x=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        s[i]=s[i-1]+x;
    }
    if(s[n]%3)cout<<0;
    else
     {
        ll res=0,cnt=0;
        for(int j=2;j<n;j++)
        {
            if(s[j-1]==s[n]/3)cnt++;
            if(s[j]==s[n]/3*2)res+=cnt;
        }
        printf("%lld",res);
     }
     return 0;
}